﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using RenChangYou.Common;

namespace DaoYou.Web.Controller
{
    public partial class ApplyDaoYou : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }

        protected void lbtnApply_Click(object sender, EventArgs e)
        {
            HttpCookie userCookie = HttpContext.Current.Request.Cookies[ConfigurationManager.AppSettings["COOKIE_KEY_USER"] as string];
            try
            {
                if (userCookie != null)
                {
                    RenChangYou.BLL.DY_User bll = new RenChangYou.BLL.DY_User();
                    RenChangYou.Model.DY_User model = bll.GetModelByCache(userCookie.Values["name"].ToString());
                    if (model != null)
                    {
                        model.UserType = 1;

                        bll.Update(model);

                        DaoYou.Web.Guider.Account.PageHelper.Current.SetCookie(model.UserName, 1);

                        Common.AlertMessageAndRedirect("申请成功，请继续完善导游信息！", Page.ResolveUrl("~/Account/UserGuiderInfo.aspx"));
                    }
                }
            }
            catch
            {
            }
        }
    }
}